package com.wdc.principles.learySubstitutionPrinciple;

import com.wdc.principles.openClosedPrinciple.SouGouInput;

public class RectangleDemo {

    public static void main(String[] args) {

        Rectangle rectangle = new Rectangle();
        rectangle.setWidth(10);
        rectangle.setLength(20);
        resize(rectangle);
        print(rectangle);
        System.out.println("==========");
        Square square = new Square();
        square.setWidth(20);
        resize(square);
        print(square);
    }


    //扩宽方法
    public static void resize(Rectangle rectangle) {
        while (rectangle.getWidth() <= rectangle.getLength()) {
            rectangle.setWidth(rectangle.getWidth() + 1);
        }
    }

    //打印
    public static void print(Rectangle rectangle) {
        System.out.println(rectangle.getLength());
        System.out.println(rectangle.getWidth());

    }

}
